
EnemyModel = [ 
              {
            	  radius : 80,
            	  pos: {x:0, y:500, z:-500},
            	  color: "0xff0000",
            	  direction: {x:1, y:1, z:1},
            	  directionWeight: {x:1000,y:100,z:50000},
            	  speed:{x:30,y:40,z:30},
            	  blood: 3,
              },
              {
            	  radius : 100,
            	  pos: {x:200, y:800, z:-700},
            	  color: "0x00ff00",
            	  direction: {x:1, y:1, z:-1},
            	  directionWeight: {x:10050,y:1000,z:1080},
            	  speed:{x:30,y:40,z:30},
            	  blood: 4,
              },
              
              {
            	  radius : 70,
            	  pos: {x:-500, y:300, z:-1000},
            	  color: "0x0000ff",
            	  direction: {x:-1, y:1, z:1},
            	  directionWeight: {x:10050,y:8100,z:1080},
            	  speed:{x:30,y:40,z:30},
            	  blood: 4,
              },
              {
            	  radius : 90,
            	  pos: {x:-140, y:400, z:-100},
            	  color: "0x0000ff",
            	  direction: {x:-1, y:1, z:-1},
            	  directionWeight: {x:10050,y:1800,z:1080},
            	  speed:{x:30,y:40,z:30},
            	  blood: 5,
              },
              {
            	  radius : 80,
            	  pos: {x:-500, y:200, z:1000},
            	  color: "0x0000ff",
            	  direction: {x:1, y:1, z:-1},
            	  directionWeight: {x:1050,y:1020,z:1080},
            	  speed:{x:30,y:40,z:30},
            	  blood: 3,
              },
              {
            	  radius : 70,
            	  pos: {x:-50, y:1000, z:2000},
            	  color: "0x0000ff",
            	  direction: {x:-1, y:1, z:1},
            	  directionWeight: {x:200,y:1000,z:1080},
            	  speed:{x:30,y:40,z:30},
            	  blood: 6,
              },

              ];



Enemy = {
		enemyList: [],
		add: function(){
			for(var i=0; i<EnemyModel.length; i++){

				var enemyTexture = new THREE.ImageUtils.loadTexture(this.image);
				var enemyMaterial = new THREE.MeshLambertMaterial({
					color : EnemyModel[i].color
				});
				var sphereGeometry = new THREE.SphereGeometry(EnemyModel[i].radius, 30, 30);
				var enemy = new THREE.Mesh(sphereGeometry, enemyMaterial);
				enemy.position.set(EnemyModel[i].pos.x, EnemyModel[i].pos.y, EnemyModel[i].pos.z);
				enemy.doubleSided = true;
				enemy.rotation.x = Math.PI/2;
				enemy.receiveShadow = true;
				enemy.castShadow = true;	
				enemy.gunvoice = '';
				this.enemyList.push(enemy);
				World.scene.add(enemy);
			}
		},
		updateSingle: function(index, type){
			if(type == "c"){
				if(CameraController.isSnipe == true || ShootController.weaponType == 1){
					Explosion.setExplosionPos(EnemyModel[index].pos.x, EnemyModel[index].pos.y, EnemyModel[index].pos.z, 0);
					World.scene.remove(this.enemyList[index]);
					EnemyModel.splice(index,1);
				    Enemy.enemyList.splice(index,1);
				    TopPaneStatus.updateScore();
				    TopPaneStatus.showNote("Accurate Kill !!!");
					return;
				}
				EnemyModel[index].blood -= 1; 
				var colorValue = "0x0000bb";
//				console.log("index:" + index + " " +EnemyModel[index].blood );
				switch(EnemyModel[index].blood){
				case 3:
				colorValue = "0x0000ff";
				Explosion.setExplosionPos(EnemyModel[index].pos.x, EnemyModel[index].pos.y, EnemyModel[index].pos.z, 200);
				break;
				case 2:
				colorValue = "0x00ff00";
				Explosion.setExplosionPos(EnemyModel[index].pos.x, EnemyModel[index].pos.y, EnemyModel[index].pos.z, 200);
				break;
				case 1:
				colorValue = "0xff0000";
				Explosion.setExplosionPos(EnemyModel[index].pos.x, EnemyModel[index].pos.y, EnemyModel[index].pos.z, 200);
				break;
				case 0:
					Explosion.setExplosionPos(EnemyModel[index].pos.x, EnemyModel[index].pos.y, EnemyModel[index].pos.z, 0);
					World.scene.remove(this.enemyList[index]);
					EnemyModel.splice(index,1);
				    Enemy.enemyList.splice(index,1);
				    TopPaneStatus.updateScore();
				    TopPaneStatus.showNote("Master Kill !!!");
					

					return;
					
				default:
					Explosion.setExplosionPos(EnemyModel[index].pos.x, EnemyModel[index].pos.y, EnemyModel[index].pos.z, 200);
					return;
						
				}
//				console.log("-------");
				var enemyMaterial = new THREE.MeshLambertMaterial({
					color : colorValue
				});
				var sphereGeometry = new THREE.SphereGeometry(EnemyModel[index].radius, 30, 30);
				var enemy = new THREE.Mesh(sphereGeometry, enemyMaterial);
				enemy.position.set(EnemyModel[index].pos.x, EnemyModel[index].pos.y, EnemyModel[index].pos.z);
				enemy.doubleSided = true;
				enemy.rotation.x = Math.PI/2;
				enemy.receiveShadow = true;
				enemy.castShadow = true;
				World.scene.remove(this.enemyList[index]);
				this.enemyList.splice(index,1,enemy);
				World.scene.add(this.enemyList[index]);
			}
		},

}